<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #root {
        width: 300px;
        height: 200px;
        border: 1px solid red;
    }
</style>

<body>
    <a href="/good">good</a>
    <a href="/yes">yes</a>
    <div id="root"></div>
</body>
<script>
    let root = document.getElementById("root")
    let a = document.querySelectorAll("a")
    a.forEach((iteam) => {
        iteam.addEventListener("click", (e) => {
            e.preventDefault()
            history.pushState(null, null, e.target.href)
            let { pathname } = location;
            switch (pathname) {
                case "/good":
                    root.innerHTML = "good--good==good"
                    break;
                case "/yes":
                    root.innerHTML = "yes---yes---yes"
                    break;
                default:
                    root.innerHTML = 404
                    break;
            }

        })

    })
    // window.addEventListener("hashchange", () => {
    //     let hash = location.hash
    //     switch (hash) {
    //         case "#good":
    //             root.innerHTML = "good--good==good"
    //             break;
    //         case "#yes":
    //             root.innerHTML = "yes---yes---yes"
    //             break;
    //         default:
    //             root.innerHTML = 404
    //             break;
    //     }

    // })
</script>

</html>